package com.example.xcService.pojo.rabbitmq;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.entity.AgentOrder;
import com.example.entity.OrderPolling;
import com.example.service.IAgentOrderService;
import com.example.xcService.pojo.tool.OrderTool;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = {"refund.fanout.queue"} ,containerFactory = "listenerContainerFactory" ,concurrency = "10-50")
@Slf4j
public class RefundFanoutConsumer {
    @Autowired
    OrderTool orderTool;
    @Autowired
    IAgentOrderService agentOrderService;

    @RabbitHandler
    @Async
    public  void RefundOrder(String orderId) throws Exception{
        try{
            System.out.println(orderId);
            AgentOrder dbOrder=agentOrderService.getById(orderId);
            if (dbOrder!=null){
                orderTool.Update(dbOrder);
            }
        }catch (Exception ex){
            log.error("订单退款消息队列出错",ex);
        }
    }
}
